package com.jsgt.greekfire.ui.home.adapter

import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.fhx.core.base.BaseAdapter
import com.fhx.core.base.BaseViewHolder
import com.jsgt.greekfire.R
import com.jsgt.greekfire.bean.NavigationBean
import kotlinx.android.extensions.LayoutContainer
import kotlinx.android.synthetic.main.item_navigation.*

class NavigationAdapter(var context: Context) : BaseAdapter<NavigationBean>() {

    inner class VH(itemView: View) : BaseViewHolder(itemView) , LayoutContainer{
        override val containerView: View = itemView
        fun bindData(bean: NavigationBean) {
            nav_icon.setImageResource(bean.resId!!)
            nav_text.text = bean.name
        }
    }

    override fun provideViewHolder(parent: ViewGroup, viewType: Int): BaseViewHolder? {
        val view =
            LayoutInflater.from(parent.context).inflate(R.layout.item_navigation, parent, false)
        return VH(view)
    }

    override fun onBindViewHolder(holder: BaseViewHolder, position: Int) {
        val viewHolder = holder as VH
        viewHolder.bindData(dataList()[position])
    }
}